#[[
 * Copyright (c) 2024 iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * easyAda is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
]]

cmake_minimum_required (VERSION 3.7.2)
set(configure_string "")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/helpers.cmake)
set(KernelPlatformFind OFF)

file(GLOB result ${CMAKE_CURRENT_SOURCE_DIR}/kernel/plat/*/config.cmake)
list(SORT result)
foreach(file ${result})
    include("${file}")
endforeach()

if(NOT KernelPlatformFind) 
    message(FATAL_ERROR "Unsupported Platform")
endif()

config_choice(
    KernelArch
    ARCH
    "Architecture to use when building the kernel"
    "arm64;KernelArchARM;ARCH_ARM"
)

config_choice(KernelPlatform PLAT "Select the platform" ${kernel_platforms})
config_option(kernelSMP SMP "SMP supported" DEFAULT ON)
#config_string(NumberCPUs NR_CPUS "cpu number" DEFAULT "4" DEPENDS kernelSMP UNQUOTE)
#config_string(DefaultPriority DEFAULT_PRIORITY "default priority" DEFAULT "10" UNQUOTE)
#config_string(KernelStackPages STACK_PAGES "kernel stack pages" DEFAULT "2" UNQUOTE)
#config_string(RootServerStackPages ROOTSERVER_STACK_PAGES "rootserver stack pages" DEFAULT "8" UNQUOTE)
#config_string(IrqCount IRQ_COUNT "irq count" DEFAULT "287" UNQUOTE)
#config_string(MaxPriority MAX_PRIORITY "MAX_PRIORITY" DEFAULT "64" UNQUOTE)


# just for test
config_option(TESTVIRT TESTE "Test qemu_virt" DEFAULT ON DEPENDS  PlatformQEMUVirt)
config_option(TESTRPI4B_O TESTE "Test rpi4 opt" DEFAULT ON DEPENDS  PlatformRPI4B)
config_string(TESTRPI4B_R TESTSTR "Test rpi4b str" DEFAULT "test rpi4b" DEPENDS  PlatformRPI4B)



write_autoconfig("${CMAKE_CURRENT_SOURCE_DIR}/include/plat/${KernelPlatform}/plat/autoconf.h"  "${configure_string}")
